package com.lcm.openapi.common.exception;

import com.lcm.openapi.common.models.api.IResultCode;
import com.lcm.openapi.common.models.api.ResultCode;
import lombok.Getter;

/**
 * @author lichuanming
 * 自定义异常类
 */
@Getter
public class ServiceException extends RuntimeException {
    /**
     * 异常对应的错误类型
     */
    private final IResultCode errorType;

    /**
     * 默认是系统异常
     */
    public ServiceException() {
        this.errorType = ResultCode.ERROR;
    }

    public ServiceException(IResultCode errorType) {
        super(errorType.getMsg());
        this.errorType = errorType;
    }

    public ServiceException(IResultCode errorType, String message) {
        super(message);
        this.errorType = errorType;
    }

    public ServiceException(IResultCode errorType, String message, Throwable cause) {
        super(message, cause);
        this.errorType = errorType;
    }

    public ServiceException(String message) {
        super(message);
        this.errorType = ResultCode.ERROR;
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
        this.errorType = ResultCode.ERROR;
    }
}
